package com.datatools.ui.frame;

import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseWheelEvent;
import java.io.Serializable;

/**
 * 为RightPanel 定制的 Tab 标题关闭事件处理
 */
public class JTabMouseAdapter extends MouseAdapter implements Serializable {
    private static final long serialVersionUID=1L;
    //当前Tab 关闭按钮
    private JLabel closeBtn;
    //Tab容器
    private JTabbedPane jTabbedPane;
    //当前Tab
    private JPanel compontPanel;

    public JLabel getCloseBtn() {
        return closeBtn;
    }

    public void setCloseBtn(JLabel closeBtn) {
        this.closeBtn = closeBtn;
    }

    public JTabbedPane getjTabbedPane() {
        return jTabbedPane;
    }

    public void setjTabbedPane(JTabbedPane jTabbedPane) {
        this.jTabbedPane = jTabbedPane;
    }

    public JPanel getCompontPanel() {
        return compontPanel;
    }

    public void setCompontPanel(JPanel compontPanel) {
        this.compontPanel = compontPanel;
    }

    public JTabMouseAdapter() {
        super();
    }

    @Override
    public void mouseEntered(MouseEvent e) {
        closeBtn.setForeground(Color.RED);
    }
    @Override
    public void mouseExited(MouseEvent e) {
        closeBtn.setForeground(Color.LIGHT_GRAY);
    }
    @Override
    public void mouseClicked(MouseEvent e) {
        jTabbedPane.remove(jTabbedPane.indexOfComponent(compontPanel));
    }

}
